package simon.xianyu.task.center.db.po;

import javax.persistence.MappedSuperclass;
import javax.persistence.PrePersist;

@MappedSuperclass
abstract public class TimeEntity {
  private Long createdAt;
  private Long updatedAt;

  @PrePersist
  public void fillTime() {
    long now = System.currentTimeMillis();
    if (null == createdAt) {
      createdAt = now;
    }
    updatedAt = now;
  }

  public Long getCreatedAt() {
    return createdAt;
  }

  public void setCreatedAt(Long createdAt) {
    this.createdAt = createdAt;
  }

  public Long getUpdatedAt() {
    return updatedAt;
  }

  public void setUpdatedAt(Long updatedAt) {
    this.updatedAt = updatedAt;
  }
}
